package com.itheima.controller;

import com.itheima.pojo.User;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.bind.DefaultValue;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping(value = "/user/{id}")
    public User findById(@PathVariable("id") Integer id,String name){
        if(id==1){
            throw new RuntimeException("id为1，测试熔断");
        }else{
            System.out.println(name);
            return userService.findById(id);

        }

    }
    @RequestMapping(value= "/user2")
    public String getMyUser() {
        String result = "name334:{}";
        return "服务器太忙。请稍后重试.............";
    }
}
